\(\int (c+d x)^2 \tan ^2(a+b x) \, dx\) [255]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [B] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [B] (verification not implemented)
   Giac [F]
   Mupad [F(-1)]

Optimal result

Integrand size = 16, antiderivative size = 96 \[ \int (c+d x)^2 \tan ^2(a+b x) \, dx=-\frac {i (c+d x)^2}{b}-\frac {(c+d x)^3}{3 d}+\frac {2 d (c+d x) \log \left (1+e^{2 i (a+b x)}\right )}{b^2}-\frac {i d^2 \operatorname {PolyLog}\left (2,-e^{2 i (a+b x)}\right )}{b^3}+\frac {(c+d x)^2 \tan (a+b x)}{b} \]

[Out]

-I*(d*x+c)^2/b-1/3*(d*x+c)^3/d+2*d*(d*x+c)*ln(1+exp(2*I*(b*x+a)))/b^2-I*d^2*polylog(2,-exp(2*I*(b*x+a)))/b^3+(
d*x+c)^2*tan(b*x+a)/b

Rubi [A] (verified)

Time = 0.17 (sec) , antiderivative size = 96, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.375, Rules used = {3801, 3800, 2221, 2317, 2438, 32} \[ \int (c+d x)^2 \tan ^2(a+b x) \, dx=-\frac {i d^2 \operatorname {PolyLog}\left (2,-e^{2 i (a+b x)}\right )}{b^3}+\frac {2 d (c+d x) \log \left (1+e^{2 i (a+b x)}\right )}{b^2}+\frac {(c+d x)^2 \tan (a+b x)}{b}-\frac {i (c+d x)^2}{b}-\frac {(c+d x)^3}{3 d} \]

[In]

Int[(c + d*x)^2*Tan[a + b*x]^2,x]

[Out]

((-I)*(c + d*x)^2)/b - (c + d*x)^3/(3*d) + (2*d*(c + d*x)*Log[1 + E^((2*I)*(a + b*x))])/b^2 - (I*d^2*PolyLog[2
, -E^((2*I)*(a + b*x))])/b^3 + ((c + d*x)^2*Tan[a + b*x])/b

Rule 32

Int[((a_.) + (b_.)*(x_))^(m_), x_Symbol] :> Simp[(a + b*x)^(m + 1)/(b*(m + 1)), x] /; FreeQ[{a, b, m}, x] && N
eQ[m, -1]

Rule 2221

Int[(((F_)^((g_.)*((e_.) + (f_.)*(x_))))^(n_.)*((c_.) + (d_.)*(x_))^(m_.))/((a_) + (b_.)*((F_)^((g_.)*((e_.) +
 (f_.)*(x_))))^(n_.)), x_Symbol] :> Simp[((c + d*x)^m/(b*f*g*n*Log[F]))*Log[1 + b*((F^(g*(e + f*x)))^n/a)], x]
 - Dist[d*(m/(b*f*g*n*Log[F])), Int[(c + d*x)^(m - 1)*Log[1 + b*((F^(g*(e + f*x)))^n/a)], x], x] /; FreeQ[{F,
a, b, c, d, e, f, g, n}, x] && IGtQ[m, 0]

Rule 2317

Int[Log[(a_) + (b_.)*((F_)^((e_.)*((c_.) + (d_.)*(x_))))^(n_.)], x_Symbol] :> Dist[1/(d*e*n*Log[F]), Subst[Int
[Log[a + b*x]/x, x], x, (F^(e*(c + d*x)))^n], x] /; FreeQ[{F, a, b, c, d, e, n}, x] && GtQ[a, 0]

Rule 2438

Int[Log[(c_.)*((d_) + (e_.)*(x_)^(n_.))]/(x_), x_Symbol] :> Simp[-PolyLog[2, (-c)*e*x^n]/n, x] /; FreeQ[{c, d,
 e, n}, x] && EqQ[c*d, 1]

Rule 3800

Int[((c_.) + (d_.)*(x_))^(m_.)*tan[(e_.) + (f_.)*(x_)], x_Symbol] :> Simp[I*((c + d*x)^(m + 1)/(d*(m + 1))), x
] - Dist[2*I, Int[(c + d*x)^m*(E^(2*I*(e + f*x))/(1 + E^(2*I*(e + f*x)))), x], x] /; FreeQ[{c, d, e, f}, x] &&
 IGtQ[m, 0]

Rule 3801

Int[((c_.) + (d_.)*(x_))^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[b*(c + d*x)^m*((b*Tan[e
 + f*x])^(n - 1)/(f*(n - 1))), x] + (-Dist[b*d*(m/(f*(n - 1))), Int[(c + d*x)^(m - 1)*(b*Tan[e + f*x])^(n - 1)
, x], x] - Dist[b^2, Int[(c + d*x)^m*(b*Tan[e + f*x])^(n - 2), x], x]) /; FreeQ[{b, c, d, e, f}, x] && GtQ[n,
1] && GtQ[m, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {(c+d x)^2 \tan (a+b x)}{b}-\frac {(2 d) \int (c+d x) \tan (a+b x) \, dx}{b}-\int (c+d x)^2 \, dx \\ & = -\frac {i (c+d x)^2}{b}-\frac {(c+d x)^3}{3 d}+\frac {(c+d x)^2 \tan (a+b x)}{b}+\frac {(4 i d) \int \frac {e^{2 i (a+b x)} (c+d x)}{1+e^{2 i (a+b x)}} \, dx}{b} \\ & = -\frac {i (c+d x)^2}{b}-\frac {(c+d x)^3}{3 d}+\frac {2 d (c+d x) \log \left (1+e^{2 i (a+b x)}\right )}{b^2}+\frac {(c+d x)^2 \tan (a+b x)}{b}-\frac {\left (2 d^2\right ) \int \log \left (1+e^{2 i (a+b x)}\right ) \, dx}{b^2} \\ & = -\frac {i (c+d x)^2}{b}-\frac {(c+d x)^3}{3 d}+\frac {2 d (c+d x) \log \left (1+e^{2 i (a+b x)}\right )}{b^2}+\frac {(c+d x)^2 \tan (a+b x)}{b}+\frac {\left (i d^2\right ) \text {Subst}\left (\int \frac {\log (1+x)}{x} \, dx,x,e^{2 i (a+b x)}\right )}{b^3} \\ & = -\frac {i (c+d x)^2}{b}-\frac {(c+d x)^3}{3 d}+\frac {2 d (c+d x) \log \left (1+e^{2 i (a+b x)}\right )}{b^2}-\frac {i d^2 \operatorname {PolyLog}\left (2,-e^{2 i (a+b x)}\right )}{b^3}+\frac {(c+d x)^2 \tan (a+b x)}{b} \\ \end{align*}

Mathematica [B] (verified)

Both result and optimal contain complex but leaf count is larger than twice the leaf count of optimal. \(276\) vs. \(2(96)=192\).

Time = 6.40 (sec) , antiderivative size = 276, normalized size of antiderivative = 2.88 \[ \int (c+d x)^2 \tan ^2(a+b x) \, dx=-\frac {1}{3} x \left (3 c^2+3 c d x+d^2 x^2\right )+\frac {2 c d \sec (a) (\cos (a) \log (\cos (a) \cos (b x)-\sin (a) \sin (b x))+b x \sin (a))}{b^2 \left (\cos ^2(a)+\sin ^2(a)\right )}+\frac {d^2 \csc (a) \left (b^2 e^{-i \arctan (\cot (a))} x^2-\frac {\cot (a) \left (i b x (-\pi -2 \arctan (\cot (a)))-\pi \log \left (1+e^{-2 i b x}\right )-2 (b x-\arctan (\cot (a))) \log \left (1-e^{2 i (b x-\arctan (\cot (a)))}\right )+\pi \log (\cos (b x))-2 \arctan (\cot (a)) \log (\sin (b x-\arctan (\cot (a))))+i \operatorname {PolyLog}\left (2,e^{2 i (b x-\arctan (\cot (a)))}\right )\right )}{\sqrt {1+\cot ^2(a)}}\right ) \sec (a)}{b^3 \sqrt {\csc ^2(a) \left (\cos ^2(a)+\sin ^2(a)\right )}}+\frac {\sec (a) \sec (a+b x) \left (c^2 \sin (b x)+2 c d x \sin (b x)+d^2 x^2 \sin (b x)\right )}{b} \]

[In]

Integrate[(c + d*x)^2*Tan[a + b*x]^2,x]

[Out]

-1/3*(x*(3*c^2 + 3*c*d*x + d^2*x^2)) + (2*c*d*Sec[a]*(Cos[a]*Log[Cos[a]*Cos[b*x] - Sin[a]*Sin[b*x]] + b*x*Sin[
a]))/(b^2*(Cos[a]^2 + Sin[a]^2)) + (d^2*Csc[a]*((b^2*x^2)/E^(I*ArcTan[Cot[a]]) - (Cot[a]*(I*b*x*(-Pi - 2*ArcTa
n[Cot[a]]) - Pi*Log[1 + E^((-2*I)*b*x)] - 2*(b*x - ArcTan[Cot[a]])*Log[1 - E^((2*I)*(b*x - ArcTan[Cot[a]]))] +
 Pi*Log[Cos[b*x]] - 2*ArcTan[Cot[a]]*Log[Sin[b*x - ArcTan[Cot[a]]]] + I*PolyLog[2, E^((2*I)*(b*x - ArcTan[Cot[
a]]))]))/Sqrt[1 + Cot[a]^2])*Sec[a])/(b^3*Sqrt[Csc[a]^2*(Cos[a]^2 + Sin[a]^2)]) + (Sec[a]*Sec[a + b*x]*(c^2*Si
n[b*x] + 2*c*d*x*Sin[b*x] + d^2*x^2*Sin[b*x]))/b

Maple [B] (verified)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 198 vs. \(2 (88 ) = 176\).

Time = 1.58 (sec) , antiderivative size = 199, normalized size of antiderivative = 2.07

method result size
risch \(-\frac {d^{2} x^{3}}{3}-d c \,x^{2}-c^{2} x -\frac {c^{3}}{3 d}+\frac {2 i \left (x^{2} d^{2}+2 c d x +c^{2}\right )}{b \left ({\mathrm e}^{2 i \left (x b +a \right )}+1\right )}+\frac {2 d c \ln \left ({\mathrm e}^{2 i \left (x b +a \right )}+1\right )}{b^{2}}-\frac {4 d c \ln \left ({\mathrm e}^{i \left (x b +a \right )}\right )}{b^{2}}-\frac {2 i d^{2} x^{2}}{b}-\frac {4 i d^{2} x a}{b^{2}}-\frac {2 i d^{2} a^{2}}{b^{3}}+\frac {2 d^{2} \ln \left ({\mathrm e}^{2 i \left (x b +a \right )}+1\right ) x}{b^{2}}-\frac {i d^{2} \operatorname {polylog}\left (2, -{\mathrm e}^{2 i \left (x b +a \right )}\right )}{b^{3}}+\frac {4 d^{2} a \ln \left ({\mathrm e}^{i \left (x b +a \right )}\right )}{b^{3}}\) \(199\)

[In]

int((d*x+c)^2*tan(b*x+a)^2,x,method=_RETURNVERBOSE)

[Out]

-1/3*d^2*x^3-d*c*x^2-c^2*x-1/3/d*c^3+2*I*(d^2*x^2+2*c*d*x+c^2)/b/(exp(2*I*(b*x+a))+1)+2*d/b^2*c*ln(exp(2*I*(b*
x+a))+1)-4*d/b^2*c*ln(exp(I*(b*x+a)))-2*I*d^2/b*x^2-4*I*d^2/b^2*x*a-2*I*d^2/b^3*a^2+2*d^2/b^2*ln(exp(2*I*(b*x+
a))+1)*x-I*d^2*polylog(2,-exp(2*I*(b*x+a)))/b^3+4*d^2/b^3*a*ln(exp(I*(b*x+a)))

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 210 vs. \(2 (85) = 170\).

Time = 0.24 (sec) , antiderivative size = 210, normalized size of antiderivative = 2.19 \[ \int (c+d x)^2 \tan ^2(a+b x) \, dx=-\frac {2 \, b^{3} d^{2} x^{3} + 6 \, b^{3} c d x^{2} + 6 \, b^{3} c^{2} x - 3 i \, d^{2} {\rm Li}_2\left (\frac {2 \, {\left (i \, \tan \left (b x + a\right ) - 1\right )}}{\tan \left (b x + a\right )^{2} + 1} + 1\right ) + 3 i \, d^{2} {\rm Li}_2\left (\frac {2 \, {\left (-i \, \tan \left (b x + a\right ) - 1\right )}}{\tan \left (b x + a\right )^{2} + 1} + 1\right ) - 6 \, {\left (b d^{2} x + b c d\right )} \log \left (-\frac {2 \, {\left (i \, \tan \left (b x + a\right ) - 1\right )}}{\tan \left (b x + a\right )^{2} + 1}\right ) - 6 \, {\left (b d^{2} x + b c d\right )} \log \left (-\frac {2 \, {\left (-i \, \tan \left (b x + a\right ) - 1\right )}}{\tan \left (b x + a\right )^{2} + 1}\right ) - 6 \, {\left (b^{2} d^{2} x^{2} + 2 \, b^{2} c d x + b^{2} c^{2}\right )} \tan \left (b x + a\right )}{6 \, b^{3}} \]

[In]

integrate((d*x+c)^2*tan(b*x+a)^2,x, algorithm="fricas")

[Out]

-1/6*(2*b^3*d^2*x^3 + 6*b^3*c*d*x^2 + 6*b^3*c^2*x - 3*I*d^2*dilog(2*(I*tan(b*x + a) - 1)/(tan(b*x + a)^2 + 1)
+ 1) + 3*I*d^2*dilog(2*(-I*tan(b*x + a) - 1)/(tan(b*x + a)^2 + 1) + 1) - 6*(b*d^2*x + b*c*d)*log(-2*(I*tan(b*x
 + a) - 1)/(tan(b*x + a)^2 + 1)) - 6*(b*d^2*x + b*c*d)*log(-2*(-I*tan(b*x + a) - 1)/(tan(b*x + a)^2 + 1)) - 6*
(b^2*d^2*x^2 + 2*b^2*c*d*x + b^2*c^2)*tan(b*x + a))/b^3

Sympy [F]

\[ \int (c+d x)^2 \tan ^2(a+b x) \, dx=\int \left (c + d x\right )^{2} \tan ^{2}{\left (a + b x \right )}\, dx \]

[In]

integrate((d*x+c)**2*tan(b*x+a)**2,x)

[Out]

Integral((c + d*x)**2*tan(a + b*x)**2, x)

Maxima [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 418 vs. \(2 (85) = 170\).

Time = 0.39 (sec) , antiderivative size = 418, normalized size of antiderivative = 4.35 \[ \int (c+d x)^2 \tan ^2(a+b x) \, dx=\frac {i \, b^{3} d^{2} x^{3} + 3 i \, b^{3} c d x^{2} + 3 i \, b^{3} c^{2} x + 6 \, b^{2} c^{2} + 6 \, {\left (b d^{2} x + b c d + {\left (b d^{2} x + b c d\right )} \cos \left (2 \, b x + 2 \, a\right ) - {\left (-i \, b d^{2} x - i \, b c d\right )} \sin \left (2 \, b x + 2 \, a\right )\right )} \arctan \left (\sin \left (2 \, b x + 2 \, a\right ), \cos \left (2 \, b x + 2 \, a\right ) + 1\right ) + {\left (i \, b^{3} d^{2} x^{3} - 3 \, {\left (-i \, b^{3} c d + 2 \, b^{2} d^{2}\right )} x^{2} - 3 \, {\left (-i \, b^{3} c^{2} + 4 \, b^{2} c d\right )} x\right )} \cos \left (2 \, b x + 2 \, a\right ) - 3 \, {\left (d^{2} \cos \left (2 \, b x + 2 \, a\right ) + i \, d^{2} \sin \left (2 \, b x + 2 \, a\right ) + d^{2}\right )} {\rm Li}_2\left (-e^{\left (2 i \, b x + 2 i \, a\right )}\right ) - 3 \, {\left (i \, b d^{2} x + i \, b c d + {\left (i \, b d^{2} x + i \, b c d\right )} \cos \left (2 \, b x + 2 \, a\right ) - {\left (b d^{2} x + b c d\right )} \sin \left (2 \, b x + 2 \, a\right )\right )} \log \left (\cos \left (2 \, b x + 2 \, a\right )^{2} + \sin \left (2 \, b x + 2 \, a\right )^{2} + 2 \, \cos \left (2 \, b x + 2 \, a\right ) + 1\right ) - {\left (b^{3} d^{2} x^{3} + 3 \, {\left (b^{3} c d + 2 i \, b^{2} d^{2}\right )} x^{2} + 3 \, {\left (b^{3} c^{2} + 4 i \, b^{2} c d\right )} x\right )} \sin \left (2 \, b x + 2 \, a\right )}{-3 i \, b^{3} \cos \left (2 \, b x + 2 \, a\right ) + 3 \, b^{3} \sin \left (2 \, b x + 2 \, a\right ) - 3 i \, b^{3}} \]

[In]

integrate((d*x+c)^2*tan(b*x+a)^2,x, algorithm="maxima")

[Out]

(I*b^3*d^2*x^3 + 3*I*b^3*c*d*x^2 + 3*I*b^3*c^2*x + 6*b^2*c^2 + 6*(b*d^2*x + b*c*d + (b*d^2*x + b*c*d)*cos(2*b*
x + 2*a) - (-I*b*d^2*x - I*b*c*d)*sin(2*b*x + 2*a))*arctan2(sin(2*b*x + 2*a), cos(2*b*x + 2*a) + 1) + (I*b^3*d
^2*x^3 - 3*(-I*b^3*c*d + 2*b^2*d^2)*x^2 - 3*(-I*b^3*c^2 + 4*b^2*c*d)*x)*cos(2*b*x + 2*a) - 3*(d^2*cos(2*b*x +
2*a) + I*d^2*sin(2*b*x + 2*a) + d^2)*dilog(-e^(2*I*b*x + 2*I*a)) - 3*(I*b*d^2*x + I*b*c*d + (I*b*d^2*x + I*b*c
*d)*cos(2*b*x + 2*a) - (b*d^2*x + b*c*d)*sin(2*b*x + 2*a))*log(cos(2*b*x + 2*a)^2 + sin(2*b*x + 2*a)^2 + 2*cos
(2*b*x + 2*a) + 1) - (b^3*d^2*x^3 + 3*(b^3*c*d + 2*I*b^2*d^2)*x^2 + 3*(b^3*c^2 + 4*I*b^2*c*d)*x)*sin(2*b*x + 2
*a))/(-3*I*b^3*cos(2*b*x + 2*a) + 3*b^3*sin(2*b*x + 2*a) - 3*I*b^3)

Giac [F]

\[ \int (c+d x)^2 \tan ^2(a+b x) \, dx=\int { {\left (d x + c\right )}^{2} \tan \left (b x + a\right )^{2} \,d x } \]

[In]

integrate((d*x+c)^2*tan(b*x+a)^2,x, algorithm="giac")

[Out]

integrate((d*x + c)^2*tan(b*x + a)^2, x)

Mupad [F(-1)]

Timed out. \[ \int (c+d x)^2 \tan ^2(a+b x) \, dx=\int {\mathrm {tan}\left (a+b\,x\right )}^2\,{\left (c+d\,x\right )}^2 \,d x \]

[In]

int(tan(a + b*x)^2*(c + d*x)^2,x)

[Out]

int(tan(a + b*x)^2*(c + d*x)^2, x)